
export function groupBy( arr: any[], generateKey: Function | string ){
    if( typeof generateKey == 'string' ){
        const propname = generateKey
        generateKey = ( item: any ) => item[propname]
    }
    const result: any = {}
    for( const item of arr ){
        const key = generateKey( item )
        if( !result[key] ){
            result[key] = []
        }
        result[key].push(item)
    }
    return result
}